<%@ page language="java"
	import="java.util.*,news.dao.*,news.entity.*,utilu.*"
	pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'doaddcomments.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>
	<%//获取评论的用户名字
	request.setCharacterEncoding("utf-8");
   String cauthor=request.getParameter("cauthor");
   //获取ip
   String cip=request.getParameter("cip");
   //获取评论内容
      String ccontent=request.getParameter("ccontent");
  //获取cnid 新闻的编号
  int cnid=Integer.parseInt(request.getParameter("cnid"));
  //new一个新闻对象
  Comments co=new Comments();
  //获取添加的时间
  Date da = new Date();
		co.setCdate(DBUtil.datestring(da));
		co.setCauthor(cauthor);
		co.setCcontent(ccontent);
		co.setCip(cip);
		co.setCnid(cnid);
 int bo=  CommentsDao.com.addComments(co);
 if(bo>0){%>
	<script type="text/javascript">
		alert("评论成功！");
		location = "news.jsp?nid=<%=cnid%>";
	</script>

	<%	}else{%>
	<script type="text/javascript">
		alert("评论失败！");
		location = "news.jsp?nid=<%=cnid%>";
	</script>
	<% }
    %>
</body>
</html>
